import 'package:baselib/base/base_view.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'get_two_list_page.dart';
import '../viewmodel/get_two_main_tab_view_model.dart';

class GetTwoMainTabPage extends StatefulWidget {
  @override
  _GetTwoMainTabPageState createState() => _GetTwoMainTabPageState();
}

class _GetTwoMainTabPageState extends State<GetTwoMainTabPage> with TickerProviderStateMixin{
  @override
  Widget build(BuildContext context) {
    return BaseView(
      model: GetTwoMainTabViewModel(
          tickerProvider:this
      ),
      builder: (GetTwoMainTabViewModel model){
        return Scaffold(
          appBar: AppBar(
            // title: Text('${controller.arguments['name']} is UserEntity ${controller.arguments['userEntity'] is UserEntity}'),
            title: Obx(()=>Text('${model?.arguments['name']}\n${model?.userEntity?.value?.name}')),
          ),
          body: Column(
            children: [
              Container(
                width: Get.size.width,
                child: TabBar(
                  controller: model?.tabController,
                  tabs: model?.tabs,
                  labelColor: Colors.blue,
                  unselectedLabelColor: Colors.black12,
                  labelPadding: EdgeInsets.only(
                    top: 15,
                    bottom: 15,
                  ),
                ),
              ),
              Expanded(child:
              TabBarView(
                  controller: model?.tabController,
                  children: model?.tabs?.map((e) => GetTwoListPage(tag: '${e}',))?.toList()
              )
              )
            ],
          ),
        );
      },
    );
  }
}
